package com.example.zgdemo.controller;

import com.example.zgdemo.aop.RateLimit;
import com.example.zgdemo.req.SeckillReq;
import com.example.zgdemo.service.SeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    SeckillService seckillService;
    @GetMapping("/api/test")
    @RateLimit(value = "/api/test", capacity = 10, rate = 2)
    public String test() {
        return "Success";
    }



    @PostMapping("/api/seckill")
    @RateLimit(value = "/api/seckill", capacity = 10, rate = 2)
    public String seckill(@RequestBody SeckillReq req) {
        seckillService.seckill(req);
        return "Success";
    }
}
